const bodyParser = require('body-parser')
const isProduction = process.env.NODE_ENV === 'production'

let feMock
if (!isProduction) {
  feMock = require('./mockApi')
}
module.exports = {
  publicPath: isProduction ? '././' : '',
  pages: {
    index: {
      entry: 'src/main.js',
      template: 'public/index.html',
      filename: 'index.html'
    }
  },
  devServer: {
    before: app => {
      // 关键代码
      app.use(bodyParser.json())
      app.use(bodyParser.urlencoded({ extended: true }))
      if (!isProduction) {
        feMock(app)
      }
    }
  }
}
